<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			div {
				width: 100px;
				height: 100px;
				background-color: orange;
			}
		</style>
	</head>
	<body>
		<div>1</div>
		<div>2</div>
		<div>3</div>
		<script type="text/javascript">
			var divs = document.querySelectorAll("div");
			divs[0].onclick = function() {
				alert(11);
				//1.传统方式删除时间
				divs[0].onclick = null;
			}

			//2.removeEventListener 删除事件
			divs[1].addEventListener("click", fn);

			function fn() {
				alert("222");
				divs[1].removeEventListener("click", fn);
			}

			//3.旧版 IE专用
			divs[2].attachEvent("onclick", fn1);

			function fn1() {
				alert(232);
				divs[2].detachEvent("onclick", fn1);
			}
		</script>
	</body>
</html>
